<%@ page language="java" contentType="text/html; charset=UTF-8"
               pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <%@ include file="/sysoutUtil/inc.jsp" %>
    <title>企业列表</title>
</head>
<body>
<table class="table" id="emp-table" border="1"></table>
<div id="updateOrgDialog"></div>
<script>
    $(function(){
        SelectAuthOrgInfo();
    })
    function SelectAuthOrgInfo(){
        $.ajax({
            url:'http://localhost:8071/AuthOrgInfo/SelectAuthOrgInfo',
            type:'get',
            dataType:'json',
            success:function(data){
                var examStatus = 2;
                var examStatus2 = 3;
                var str = '<tr>\n' +
                    '<td>主键</td>\n' +
                    '<td>组织团体名称</td>\n' +
                    '<td>组织团体类型</td>\n' +
                    '<td>认证状态</td>\n' +
                    '<td>详细信息</td>\n' +
                    '<td>证件到期时间</td>\n' +
                    '<td>详细地址</td>\n' +
                    '<td>操作</td>\n' +
                    '</td>\n' +
                    '</tr>'
                for ( var i = 0; i < data.length; i++) {
                    var examStatus3="";
                    var examStatus1 = data[i].examStatus;
                    if(examStatus1==1){
                        examStatus3="请求认证"
                    }else{
                        examStatus3="认证失败"
                    }
                    str +=
                        '<tr>\n' +
                        '<td>'+data[i].orgId+'</td>\n' +
                        '<td>'+data[i].orgName+'</td>\n' +
                        '<td>'+data[i].orgType+'</td>\n' +
                        '<td>'+examStatus3+'</td>\n' +
                        '<td>'+data[i].orgInfo+'</td>\n' +
                        '<td>'+data[i].orgTermTime+'</td>\n' +
                        '<td>'+data[i].orgPlce+'</td>\n' +
                        "<td><input type='button'value='认证通过'onclick='updateYes("+data[i].orgId+","+examStatus+","+data[i].userId+")'> <input type='button'value='认证驳回'onclick='updateNo("+data[i].orgId+","+examStatus2+","+data[i].userId+")'> </td>\n"+
                        '</td>\n'+
                        '</tr>'
                }
                $("#emp-table").html(str)

            }
        })
    }


    function updateNo(orgId,examStatus2,userid){
        alert(orgId+"---"+examStatus2+"-----"+userid)
        $.ajax({
            url:'http://localhost:8071/AuthOrgInfo/UpdateAuthOrgInfo',
            data:{
                "orgId":orgId,
                "examStatus":examStatus2,
                "userid":userid
            },
            type:'put',
            dataType:'json',
            success:function(data){
                if(data==1){
                    //alert("成功");
                    location.href=location;
                }else{
                    alert("失败");
                    SelectAuthOrgInfo();
                }

            }
        })
    }
    function updateYes(orgId,examStatus,userid){
        alert(orgId+"---"+examStatus+"-----"+userid)
        $.ajax({
            url:'http://localhost:8071/AuthOrgInfo/UpdateAuthOrgInfo',
            data:{
                "orgId":orgId,
                "examStatus":examStatus,
                "userid":userid
            },
            type:'put',
            dataType:'json',
            success:function(data){
                if(data==1){
                    alert("成功")
                }else{
                    alert("失败")
                }

            }
    })
    }

</script>

</body>
</html>
